package com.example.questionario;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.questionario.control.FileManager;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		//resetar variaveis
		
		////
		
		/////
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button iniciar= (Button) findViewById(R.id.botaoIniciar);
		iniciar.setOnClickListener(new Button.OnClickListener() {		
			@Override
			public void onClick(View arg0) {
				
				FileManager fm= new FileManager(MainActivity.this); 
				fm.WriteFile("teste, teste2, tste3");
				
				iniciar();
			}
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}	
	
	public void iniciar(){
		Intent intent = new Intent(this, Pag1.class);
		startActivity(intent);	
		finish();
	}
	
	float startX = 0, endX= 0;
	public boolean onTouchEvent(MotionEvent event) {
		//dumpEvent(event);
		
		switch (event.getAction() & MotionEvent.ACTION_MASK) {

		case MotionEvent.ACTION_DOWN:
			startX= event.getX();
			//Log.d("MOVE", ">>");
			return true;
		case MotionEvent.ACTION_UP:
			endX= event.getX();
			if(endX>startX){			
					
			}else{
				float res= (startX - endX);
				Log.d("MOVE", Float.toString(res));
				if(res>125){
					Intent intent = new Intent(this, Pag1.class);	
					overridePendingTransition(android.R.anim.fade_out, android.R.anim.fade_in);	
					startActivity(intent);							
						finish();
				}
				return true;					
		}
		return false;
		}
		return false;
	}
}
